package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.BankOpen;
import com.ruoyi.system.service.IBankOpenService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 银行开户Controller
 * 
 * @author ruoyi
 * @date 2025-10-23
 */
@RestController
@RequestMapping("/open")
public class BankOpenController extends BaseController
{
    @Autowired
    private IBankOpenService bankOpenService;

    /**
     * 查询银行开户列表
     */
    @RequiresPermissions("system:open:list")
    @GetMapping("/list")
    public TableDataInfo list(BankOpen bankOpen)
    {
        startPage();
        List<BankOpen> list = bankOpenService.selectBankOpenList(bankOpen);
        return getDataTable(list);
    }

    /**
     * 导出银行开户列表
     */
    @RequiresPermissions("system:open:export")
    @Log(title = "银行开户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BankOpen bankOpen)
    {
        List<BankOpen> list = bankOpenService.selectBankOpenList(bankOpen);
        ExcelUtil<BankOpen> util = new ExcelUtil<BankOpen>(BankOpen.class);
        util.exportExcel(response, list, "银行开户数据");
    }

    /**
     * 获取银行开户详细信息
     */
    @RequiresPermissions("system:open:query")
    @GetMapping(value = "/{bankOpenInfoId}")
    public AjaxResult getInfo(@PathVariable("bankOpenInfoId") Long bankOpenInfoId)
    {
        return success(bankOpenService.selectBankOpenByBankOpenInfoId(bankOpenInfoId));
    }

    /**
     * 新增银行开户
     */
    @RequiresPermissions("system:open:add")
    @Log(title = "银行开户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BankOpen bankOpen)
    {
        return toAjax(bankOpenService.insertBankOpen(bankOpen));
    }

    /**
     * 修改银行开户
     */
    @RequiresPermissions("system:open:edit")
    @Log(title = "银行开户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BankOpen bankOpen)
    {
        return toAjax(bankOpenService.updateBankOpen(bankOpen));
    }

    /**
     * 删除银行开户
     */
    @RequiresPermissions("system:open:remove")
    @Log(title = "银行开户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bankOpenInfoIds}")
    public AjaxResult remove(@PathVariable Long[] bankOpenInfoIds)
    {
        return toAjax(bankOpenService.deleteBankOpenByBankOpenInfoIds(bankOpenInfoIds));
    }
}
